#!/usr/bin/env python
# -*- coding: utf-8 -*-

from random import randint
from register import Favor

def register_new():
    emailfp = open('email.txt')
    passwordfp = open('password.txt')
    namefp = open('new_name.txt')
    collagefp = open('collages.txt')

    emails = emailfp.readlines()
    passwords = passwordfp.readlines()
    names = namefp.readlines()
    collages = collagefp.readlines()

    for i in range(10):
        email = emails[randint(0, len(emails)-1)].strip()
        password = passwords[randint(0, len(passwords)-1)].strip()
        name = names[randint(0, len(names)-1)].strip()
        collage = collages[randint(0, len(collages)-1)].strip()

        # print email+'-'+password+'-'+name+'-'+collage
        A = Favor()
        A.register(email, password, name, collage)
        A.login()
        for j in ['43', '99', '110']:
            A.PraiseDaily_auto(j)

def login_old():
    oldfp = open('userlist')
    userlist = oldfp.readlines()
    for user in userlist:
        username, password = user.split(' ')
        username = username.strip()
        password = password.strip()

        A = Favor()
        A.login(username, password)
        for j in ['43', '99', '110']:
            A.PraiseDaily_auto(j)
    oldfp.close()

if __name__ == '__main__':
    login_old()
    register_new()
